<template>
  <div class="xtx-step">
    <div class="item" :class="{active:currStep>i}" v-for="(item, i) in steps" :key="i">
      <div class="step">
        <div class="line line-left" v-if="i > 0"></div>
        <div class="num">{{ i + 1 }}</div>
        <div class="line line-right" v-if="i < steps.length - 1"></div>
      </div>
      <div class="title">{{ item.title }}</div>
      <div class="desc" v-if="item.desc">{{ item.desc }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'xtx-step',
  props: {
    steps: {
      type: Array,
      default: () => []
    },
    currStep: {
      type: Number,
      default: 0
    }
  }
}
</script>

<style scoped lang='less'>
.xtx-step {
  width: 100%;
  display: flex;
  user-select: none;
  .item {
    flex: 1;
    text-align: center;
    .step {
      height: 48px;
      position: relative;
      .num {
        width: 48px;
        height: 48px;
        border: 2px solid #e4e4e4;
        border-radius: 50%;
        line-height: 44px;
        font-size: 28px;
        color: #ccc;
        margin: 0 auto;
        position: relative;
        z-index: 1;
        background-color: #fff;
      }
      .line {
        position: absolute;
        top: 23px;
        height: 2px;
        background-color: #e4e4e4;
        width: 50%;
        &-left {
          left: 0;
        }
        &-right {
          left: 50%;
        }
      }
    }
    .title {
      margin-top: 15px;
      color: #999;
    }
    .desc {
      margin-top: 5px;
      color: #999;
      font-size: 12px;
    }
    &.active {
      .step {
        .num {
          border-color: @xtxColor;
          background-color: @xtxColor;
          color: #fff;
        }
        .line {
          background-color: @xtxColor;
        }
      }
      .title {
        color: @xtxColor;
      }
    }
  }
}
</style>
